home *** CD-ROM | disk | FTP | other *** search
- Path: nntp-xfer-2.csn.net!yuma!steffend
- From: steffend@lamar.colostate.edu (Dave Steffen)
- Newsgroups: comp.lang.c++
- Subject: Re: Newbie question on syntax of pointer to const
- Date: 30 Jan 1996 17:40:41 GMT
- Organization: Colorado State University, Fort Collins, CO 80523
- Message-ID: <4ell6p$3f2q@yuma.ACNS.ColoState.EDU>
- References: <4ej9eg$lq6@agate.berkeley.edu> <4ek468$jr1@clarknet.clark.net>
- NNTP-Posting-Host: glitch.physics.colostate.edu
- X-Newsreader: TIN [version 1.2 PL2]
-
- Harlan Messinger (gusty@clark.net) wrote:
- > parsons@vouvray.CS.Berkeley.EDU (David C. Parsons) wrote:
- > >(1) const double *pc; and
- > >(2) double const *pc;
-
- > This is one of my favorite questions to ask C/C++ programmers at job
- > interviews.
-
- > They are different. The first is a pointer to a constant double.
- (snip)
- > The second is a constant pointer to a double.
- (snip)
-
- What I'm curious about is the syntax of that second
- line. Looking at Meyers' book, it looks like the const should come
- after the *. In other words, are these the same:
-
- double const * pc;
- double * const pc;
-
- The second syntax I've seen and used; the first I'm not sure
- of (and am too lazy to check the DWP right now ;-)
-
- /\
- \/
-
- Dave Steffen No, his mind is not for rent
- Dept. of Physics To any God or Government
- Colorado State University Always hopeful, yet discontent
- steffend@lamar.colostate edu He knows changes aren't permanent-
- But change is...
- "Speak softly...
- ... and carry a black belt!" -Neal Peart / RUSH
- -----------------------------------------------------------------------
-